package view;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

public class ImagePanel extends JPanel {

	 /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Image img;
	private int id;

	public ImagePanel(String _img, int _id) {
		
	    this(new ImageIcon(_img).getImage());
	    this.id = _id;
	  }
	
	public ImagePanel(){}
	public ImagePanel(Image _img) {
		  super();
	    this.img=_img;
	    int width =img.getWidth(null);
	    int height = img.getHeight(null);
	    Dimension size = new Dimension(width, height);
	    setPreferredSize(size);
	    setMinimumSize(size);
	    setOpaque(false);
	    setSize(size);
	    setLayout(null);
	    
	  }	  
	  
	  public int getId()
	  {		
		  return this.id;
	  }
	  
	  
	  public void paintComponent(Graphics g) {
	      g.drawImage(this.img, 0, 0, null);	    
	  }
	  
	  public Image getImage()
	  {
		  return this.img;
	  }
	  public void setImage(Image _img)
	  {
		  this.img = _img;
		  this.repaint();
	  }

	}

